from app.models.Users import Users


class UserService(object):
    @staticmethod
    def get_user_by_id(user_id: int):
        return Users.find(user_id)

    @staticmethod
    def get_user_by_username(username: str):
        return 'aa'

    @staticmethod
    def update_openid(uid: int, openid: str):
        return 'aa'

    @staticmethod
    def user_list(page, pagesize):
        return Users.paginate(pagesize, page)

    @staticmethod
    def user_log_list(page, pagesize):
        return 'aa'

    @staticmethod
    def vip_record(pid, page, pagesize):
        return 'aa'

    @staticmethod
    def update_vip_record(order_sn):
        return True

    @staticmethod
    def create_user(openid: str):
        data = {
            'nickName': '微信用户',
            "avatarUrl": 'https://img1.baidu.com/it/u=2814135834,1483541543&fm=253&fmt=auto&app=138&f=JPEG',
            "gender": 1,
            "openid": openid,
        }
        return Users.create(**data)
